<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Projekti</title>
        <h:outputStylesheet library="css" name="styles.css"/> 
    </h:head>
    <h:body>
        <ui:include src="adminMenuBar.xhtml"/>
        <h:form>
            <p:panel header="Predmeti" styleClass="headerPanel"> 
                <p:fieldset legend="Dodaj predmet" toggleable="true" toggleSpeed="500" collapsed="true">

                    <h:panelGrid columns="2">
                        <h:outputLabel value="Naziv:"/>
                        <p:inputText value="#{adminBean.newP.naziv}"/>
                        <h:outputLabel value="Sifra:"/>
                        <p:inputText value="#{adminBean.newP.sifra}"/>
                        <h:outputLabel value="Status:"/>
                        <p:selectOneMenu value="#{adminBean.newP.tip}">
                            <f:selectItems value="#{adminBean.typeList}"/>
                        </p:selectOneMenu>
                        <h:outputLabel value="ESPB:"/>
                        <p:inputText  value="#{adminBean.newP.semestar}"/>
                        <h:outputLabel value="ESPB:"/>
                        <p:inputText  value="#{adminBean.newP.espb}"/>
                        <h:outputLabel value="Fond casova: "/>
                        <p:inputMask  value="#{adminBean.newP.fondCasova}" mask="9+9+9"/>
                    </h:panelGrid>
                    <h:outputLabel value="Uslov:"/>
                    <br/><br/>
                    <p:editor width="600" value="#{adminBean.newP.propozicije}"/>
                    <br/><br/>

                    <h:outputLabel value="Informacije:"/>
                    <br/><br/>
                    <p:editor width="600" value="#{adminBean.newP.informacije}"/>
                    <br/><br/>

                    <h:outputLabel value="Cilj predmeta:"/>
                    <br/>  <br/>
                    <p:editor width="600" />

                    <br/>
                    <p:commandButton value="Dodaj" action="#{adminBean.addCourse()}" ajax="false"/>

                </p:fieldset> <br/>
                <p:fieldset legend="Dodaj lab" toggleable="true" toggleSpeed="500" collapsed="true">

                    <h:panelGrid columns="2">
                        <p:outputLabel value="Predmet: "/>
                        <p:selectOneMenu value="#{adminBean.selectedP}" var="p" converter="courseConverter">
                            <f:selectItems value="#{adminBean.PList}" var="predmet" itemLabel="#{predmet.naziv} - #{predmet.sifra}" itemValue="#{predmet}"/>
                            <p:column>
                                #{p.naziv} - #{p.sifra}
                            </p:column>
                        </p:selectOneMenu>
                        <p:outputLabel value="Naziv: "/>
                        <p:inputText value="#{adminBean.newL.naziv}"/>
                    </h:panelGrid><br/>

                    <p:outputLabel value="Propozicije: "/> <br/><br/>
                    <p:editor value="#{adminBean.newL.propozicije}" width="600"/> <br/><br/>

                    <p:commandButton value="Dodaj" action="#{adminBean.addLab()}" ajax="false"/>

                </p:fieldset><br/>
                <p:fieldset legend="Dodaj domaci" toggleable="true" toggleSpeed="500" collapsed="true">
                    <h:panelGrid columns="2">
                        <p:outputLabel value="Predmet: "/>
                        <p:selectOneMenu value="#{adminBean.selectedP}" var="p" converter="courseConverter">
                            <f:selectItems value="#{adminBean.PList}" var="predmet" itemLabel="#{predmet.naziv} - #{predmet.sifra}" itemValue="#{predmet}"/>
                            <p:column>
                                #{p.naziv} - #{p.sifra}
                            </p:column>
                        </p:selectOneMenu>

                        <p:outputLabel value="Naziv: "/>
                        <p:inputText value="#{adminBean.newD.naziv}"/>
                    </h:panelGrid><br/>

                    <p:outputLabel value="Opis: "/> <br/><br/>
                    <p:editor value="#{adminBean.newD.opis}" width="600"/> <br/><br/>

                    <p:commandButton value="Dodaj" action="#{adminBean.addDomaci()}" ajax="false"/>

                </p:fieldset>
                <p:panel header="Svi predmeti">
                    <p:dataTable id="tabelaPredmeta" value="#{adminBean.PList}" var="p">
                        <p:column headerText="Naziv">
                            <p:outputLabel value="#{p.naziv}"/>
                        </p:column>
                        <p:column headerText="Sifra">
                            <p:outputLabel value="#{p.sifra}"/>
                        </p:column>
                        <p:column headerText="Katedra">
                            <p:outputLabel value="#{p.katedra.opis}"/>
                        </p:column>
                        <p:column headerText="Semestar">
                            <p:outputLabel value="#{p.semestar}"/>
                        </p:column>
                        <p:column headerText="Tip">
                            <p:outputLabel value="#{p.tip}"/>
                        </p:column>
                        <p:column headerText="Akcije">
                            <p:commandButton value="Detalji" action="#{adminBean.edit(p)}"/>
                        </p:column>
                    </p:dataTable>
                </p:panel>
            </p:panel>
        </h:form>
    </h:body>
</html>
